package com.yunhai.device.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunhai.common.dto.PaginationVo;
import com.yunhai.common.dto.Ret;
import com.yunhai.device.service.OrrOutcupStatisticsService;
import com.yunhai.model.entity.orr.OrrOutcupStatisticsEntity;
import com.yunhai.model.vo.orr.OrrOutcupStatisticsQuery;
import com.yunhai.model.vo.orr.OrrOutcupStatisticsVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/orrOutcupStatistics")
public class OrrOutcupStatisticsController {

	@Resource
	private OrrOutcupStatisticsService orrOutcupStatisticsService;


	/**
	 * 获取 OrrOutcupStatistics 分页列表
	 */
	@GetMapping("/pagination")
	public Ret getOrrOutcupStatisticsPagination(PaginationVo paginationVo, OrrOutcupStatisticsQuery orrOutcupStatisticsQuery ) throws Exception {
		IPage page = orrOutcupStatisticsService.getOrrOutcupStatisticsPagination(paginationVo, orrOutcupStatisticsQuery );
		return Ret.toPage(page);
	}


	/**
	 * 获取 OrrOutcupStatistics 所有数据
	 */
	@GetMapping("/allList")
	public Ret getOrrOutcupStatisticsAllList( OrrOutcupStatisticsQuery orrOutcupStatisticsQuery ) throws Exception {
		List<OrrOutcupStatisticsEntity> list = orrOutcupStatisticsService.getOrrOutcupStatisticsAllList( orrOutcupStatisticsQuery );
		return Ret.ok(list);
	}


	/**
	 * 获取 OrrOutcupStatistics 详情
	 */
	@GetMapping("/{id}")
	public Ret getOrrOutcupStatisticsDetailById(@PathVariable Long id) throws Exception {

	    OrrOutcupStatisticsEntity orrOutcupStatisticsEntity = orrOutcupStatisticsService.getOrrOutcupStatisticsDetail(id);
		return Ret.ok(orrOutcupStatisticsEntity);
	}


	/**
	 * 新增 OrrOutcupStatistics
	 * */
	@PostMapping("")
	public Ret addOrrOutcupStatistics(@RequestBody OrrOutcupStatisticsVo orrOutcupStatisticsVo) throws Exception {

		orrOutcupStatisticsService.addOrrOutcupStatistics(orrOutcupStatisticsVo);
		return Ret.ok();
	}


	/**
	 * 更新 OrrOutcupStatistics
	 * */
	@PutMapping("")
	public Ret updateOrrOutcupStatistics(@RequestBody OrrOutcupStatisticsVo orrOutcupStatisticsVo) throws Exception {

		orrOutcupStatisticsService.updateOrrOutcupStatistics(orrOutcupStatisticsVo);
		return Ret.ok();
	}


	/**
	 * 删除 OrrOutcupStatistics
	 * */
	@PostMapping("/batchRemove")
	public Ret batchRemoveOrrOutcupStatistics( @RequestBody List<Long> ids ) throws Exception {

	    orrOutcupStatisticsService.batchRemoveOrrOutcupStatistics(ids);
		return Ret.ok();
	}
}
